package com.project.collectAPI.comm.util;

import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SignUtil {
    public SignUtil() {
    }

    public static String genSig(String baseUrl) throws IOException {
        String str = null;
        MessageDigest md = null;

        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException var4) {
            throw new IOException(var4);
        }

        str = byte2hex(md.digest(baseUrl.getBytes("utf-8")));
        return str;
    }

    private static String byte2hex(byte[] b) {
        StringBuffer buf = new StringBuffer();

        for(int offset = 0; offset < b.length; ++offset) {
            int i = b[offset];
            if (i < 0) {
                i += 256;
            }

            if (i < 16) {
                buf.append("0");
            }

            buf.append(Integer.toHexString(i));
        }

        return buf.toString();
    }
}
